{% extends "base.html" %}
{% import "_partials/modals.html" as modals %}

{% block styles %}
  {{ super() }}
  <link rel="stylesheet" href="{{url_for('static', filename='css/main/annotate.css')}}">
{% endblock %}

{% block app_content %}
  <h1>{{ title }}</h1>

  <div id="rubric" class="row">
  	<div class="col-md-12">
  		<p>{{ rubric | safe }}</p>
  	</div>
  </div>

  <div id="graph"></div>

  <div id="wrap-buttons" class="row">
  	<div class="col-md-3 text-left">
  		<button class="btn btn-primary float-md-left" type="button" 
  			id="btn-reset">Reset</button>
  	</div>
    <div class="col-md-6 text-center">
      <p id="usage">You can zoom in and pan the graph if needed.</p>
    </div>
  	<div class="col-md-3 text-right">
  		<button class="btn btn-warning float-md-right" type="button" 
  			id="btn-none">No change points</button>
  		<button class="btn btn-success float-md-right" id="btn-submit" 
  			type="button">Submit</button>
  	</div>
  </div>
  <br>

  {{ modals.info("submitNoCP", "No Change Points Selected", "Please use the 
  \"No Change Points\" button when you think there are no change points in the 
  time series.") }}

  {{ modals.info("NoCPYesCP", "Change Points Selected", "There are selected 
  change points, please click the Reset button before clicking the \"No change 
  points\" button.") }}

  <h3>Selected Changepoints</h3>
  <div id="changepoint-table">
  	<table id="cp-table" class="table table-striped">
  	</table>
  </div>
{% endblock %}

{% block scripts %}
  {{ super() }}
  <script src="{{ bootstrap_find_resource('d3.v5.js', cdn='d3', use_minified=True) }}"></script>
  <script src="{{ url_for('static', filename='js/updateTable.js') }}"></script>
  <script src="{{ url_for('static', filename='js/buttons.js') }}"></script>
  {% if is_multi  %}
  <script src="{{ url_for('static', filename='js/makeChartMulti.js') }}"></script>
  {% else %}
  <script src="{{ url_for('static', filename='js/makeChart.js') }}"></script>
  {% endif %}
  <script>annotateChart("#graph", {{ data.chart_data | tojson }});</script>
  <script>
    // reset button
    var reset = document.getElementById("btn-reset");
    reset.onclick = resetOnClick;
    // no changepoint button
    var nocp = document.getElementById("btn-none");
    nocp.onclick = function() {
    	noCPOnClick({{ identifier }});
    };
    // submit button
    var submit = document.getElementById("btn-submit");
    submit.onclick = function() {
    	submitOnClick({{ identifier }});
    };
  </script>
{% endblock scripts %}
